﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
namespace AnyOffice.general.system.mobile_sms
{
    public partial class type_priv : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string commandText = "";
            string str2 = "";
            if (!this.Page.IsPostBack)
            {
                commandText = "SELECT ISNULL(TypePriv,'') FROM Mobile_Priv";
                str2 = ",";
                str2 = str2 + ((string)SqlHelper.ExecuteScalar(base.Conn, CommandType.Text, commandText)) + ",";
                commandText = "SELECT CodeNo,CodeName,CodeRemark FROM [dbo].[Sys_Code] WHERE CodeFlag='SMS_REMIND' AND CodeNo NOT IN ('0','10') ORDER BY CodeId ASC";
                SqlDataReader reader = SqlHelper.ExecuteReader(base.Conn, CommandType.Text, commandText);
                while (reader.Read())
                {
                    ListItem item;
                    if (reader.IsDBNull(2))
                    {
                        item = new ListItem(reader.GetString(1), reader.GetString(0));
                    }
                    else
                    {
                        item = new ListItem(reader.GetString(1) + "（" + reader.GetString(2) + "）", reader.GetString(0));
                    }
                    if (str2.IndexOf("," + reader.GetString(0) + ",") >= 0)
                    {
                        this.pklTypePriv.ItemsLeft.Add(item);
                    }
                    else
                    {
                        this.pklTypePriv.ItemsRight.Add(item);
                    }
                }
                reader.Close();
            }
            if (this.Page.IsPostBack)
            {
                this.pnlMain.Visible = false;
                foreach (ListItem item2 in this.pklTypePriv.ItemsLeft)
                {
                    str2 = str2 + item2.Value + ",";
                }
                commandText = "UPDATE Mobile_Priv SET TypePriv = '" + str2 + "'";
                SqlHelper.ExecuteNonQuery(base.Conn, CommandType.Text, commandText);
                ConfigManager.Update();
                this.litMessage.Text = base.ShowPrompt("设置已保存", "type_priv.aspx");
            }
        }

 

 

    }
}
